import { request } from 'umi';
import {Iparams} from '@/utils/interface'
import { IAllParams,IAnswerParams,IQuestionIdList, IReply, ISelectParams } from '@/utils/manageInterface';

//--------------------进度页- - - - - - -----------
export let getInfo = () => {//获取用户信息
  return request('/getInfo')
}
export let selectClassPlan = () => {//获取右侧下拉选项
  return request('/sxpt/progress/selectClassPlan')
}
export let selectClassPlanInit = (classid:string,id: string) => {//获取延期未完成人数
  return request('/sxpt/progress/selectClassPlanInit?classid='+classid+'&classPlanid='+id)
}
export let classRank = (id: string) => {//获取排行榜
  return request("/sxpt/progress/classRank?classid=9&classPlanid="+id)
}
//==========================进度页=======================

//------------------------------------------问答管理页- - - - - - --------------
export let getClassInfo = () => {//获取数据
  return request("/sxpt/classPlan/getClassInfo")
}
//获取待处理的问题
export let waitPageNum = ({pageNum,pageSize,classId,searchTitle,status}:IAllParams) => {
  return request(`/sxpt/answer/wait?pageNum=${pageNum}&pageSize=${pageSize}&classId=${classId}&searchTitle=${searchTitle}&status=${status}`)
}
//获取所有问答
export let allPageNum = ({pageNum,pageSize,classId,searchTitle,status}:IAllParams) => {
  return request(`/sxpt/answer/all?pageNum=${pageNum}&pageSize=${pageSize}&classId=${classId}&searchTitle=${searchTitle}&status=${status}`)
}
//提交回答
export let replyRightAnswer = (data:IQuestionIdList) => {
  return request("/sxpt/answer/replyRightAnswer", {
    method: "post",
    data
  })
}
//每一项回答
export let answerList = ({pageNum,pageSize,answerId,isScort,status}:IAnswerParams) => {
  return request(`/sypt/reply/answerList?answerId=${answerId}&status=${status}&isScort=${isScort}&pageNum=${pageNum}&pageSize=${pageSize}`)
}
//批量选择相似答案
export let selectAnswerList = ({pageNum,pageSize,isRight,type,questionTitle}:ISelectParams) => {
  return request(`/sxpt/askAndAnswer/selectAnswerList?questionTitle=${questionTitle}&type=${type}&isRight=${isRight}&pageNum=${pageNum}&pageSize=${pageSize}`)
}
// 设为精品
export let qualityAnswerId = (id:string) => {
  return request(`/sxpt/answer/quality?answerId=${id}`)
}
// 取消精品
export let deleteQualityAnswerId = (id:string) => {
  return request(`/sxpt/answer/deleteQuality?answerId=${id}`)
}
// 获取详情/sypt/answer/reply
export let answerDetail = (id:string) => {
  return request(`/sypt/answer/${id}`)
}
// 回答
export let reply = (params:IReply) => {
  return request(`/sypt/answer/reply`, {
    method: 'post',
    data:params
  })
}
//====================================问答管理页================================

//-------------------------登录页----------------------------------------
export let getCaptchaImage = () => {
  return request('/captchaImage')
}
export let login = (params:Iparams) => {
  return request('/login', {
    method: 'post',
    data:params
  })
}
//================================登录页==========================
